#ifndef _RISCV_H_
#define _RISCV_H_

typedef unsigned long uint64;
typedef unsigned int uint32;

// CSR寄存器读写
static inline uint64 r_satp() {
    uint64 x;
    asm volatile("csrr %0, satp" : "=r" (x));
    return x;
}

static inline void w_satp(uint64 x) {
    asm volatile("csrw satp, %0" : : "r" (x));
}

// TLB刷新
static inline void sfence_vma() {
    asm volatile("sfence.vma zero, zero");
}

#endif // _RISCV_H_
